#@layout()

#define content()

<section class="content-header">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6">

                <div class="row mb-2">
                    <div class="col-sm-12">
                        <h1>
                            #if(datasourceItem.id ??) 编辑数据 #else 新增数据 #end
                            <small data-toggle="tooltip" title="" data-placement="right"
                                   data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                            <small> 首页 / 表单 / 数据源 / 数据管理 /  #if(datasourceItem.id ??) 编辑 #else 新增 #end </small>
                        </h1>
                    </div>
                </div>
            </div>
        </div>

    </div><!-- /.container-fluid -->
</section>

<section class="content">
    <div class="row">
        <div class="col-12">
            <div class="card card-outline card-primary">
                <form class="form-setting autoAjaxSubmit" autocomplete="off"
                      action="#(CPATH)/admin/form/datasource/item/doSave"
                      data-ok-href="#(CPATH)/admin/form/datasource/item/#(datasource.id ??)"
                      method="POST">

                    <div class="card-body ">
                        <input type="hidden" id="entryId" name="datasourceItem.id" value="#(datasourceItem.id ??)">
                        <input type="hidden" name="datasourceItem.datasource_id" value="#(datasource.id ??)">

                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">归属数据源</label>
                            <div class="col-sm-6">

                                <input type="text" value="#(datasource.name ??)" class="form-control" readonly>

                            </div>
                        </div>


                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">value 值</label>
                            <div class="col-sm-6">

                                <input type="text" name="datasourceItem.value" class="form-control"
                                       value="#(datasourceItem.value ??)"
                                       placeholder="请输入 value 值">
                            </div>
                        </div>


                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">显示文本</label>
                            <div class="col-sm-6">

                                <input type="text" name="datasourceItem.text" class="form-control"
                                       value="#(datasourceItem.text ??)"
                                       placeholder="">
                            </div>
                        </div>



                        #if(datasource.with_cascade ??)
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">上级ID</label>
                            <div class="col-sm-6">

                                <select name="datasourceItem.pid" class="form-control">
                                    <option value="0">顶级</option>
                                    #for(item : datasourceItemList)
                                    #if(item.id ?? != datasourceItem.id ??)
                                    <option value="#(item.id ??)" #if(item.id ?? == datasourceItem.pid ??) selected #end>#(item.value ??)</option>
                                    #end
                                    #end
                                </select>

                            </div>
                        </div>
                        #end






                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">图片</label>
                            <div class="col-sm-9">
                                <div class="jpress-image-browser">
                                    <input type="hidden" name="datasourceItem.image" value="#(datasourceItem.image ??)"/>
                                    <img src="#(datasourceItem.image ?? '/static/commons/img/nothumbnail.jpg')">
                                    <div class="image-action">
                                        <a class="image-delete"> <i class="fa fa-trash"></i></a>
                                        <a class="image-edit"> <i class="fa fa-edit"></i></a>
                                    </div>
                                </div>
                                <p class="text-muted"> </p>

                            </div>
                        </div>

                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="offset-sm-2 col-sm-10 submit-block">
                            <div class="card-submit">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->
                </form>
            </div>
        </div>
    </div>

</section>

#end
